package org.example.bean;

import org.aopalliance.intercept.Joinpoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author liht
 */
@Component
@Aspect
public class AdastorComponent {

    @Pointcut("execution(public * org.example.bean.UserService.*(..))")
    public void invokeFacade() {
    }

    @Around("invokeFacade()")
    public Object round(ProceedingJoinPoint joinPoint) {
        try {
            System.out.println("before");
            Object proceed = joinPoint.proceed();
            System.out.println("after");
            return proceed;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return null;
    }
}
